﻿using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using Abp.UI;
using ARchGL.Platform.Authorization.Users;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;

namespace ARchGL.Platform.Core
{
    //public class TableNameAttribute : TableAttribute
    //{
    //    public TableAttribute(string name)
    //    {
    //        this.Name = name;
    //    }
    //}

    /// <summary>
    /// 项目 数据实体
    /// </summary>
    [Table("JN_" + nameof(Projects))]
    public class Projects : EntitySoftDeleteBase
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 编号
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 地址
        /// </summary>
        public string Address { get; set; }
        /// <summary>
        /// 项目类型：(选项)安装工程1/地灾设计2/地灾施工工程3/房建工程4/非煤矿山5/钢结构工程6/公路工程7/矿建工程8/桥梁工程9/市政工程10/水利电力工程11/隧道工程12/铁路工程13/土地政治工程14/土石方工程15/消防工程16/装饰工程17/综合18/其他19
        /// </summary>
        public EnumProjectType Type { get; set; }
        /// <summary>
        /// 是否系统项目，该字段不能被编辑（为 True 的数据不能删除，只能编辑，系统自动初始化）
        /// </summary>
        public bool IsSystem { get; set; }

        /// <summary>
        /// 项目状态
        /// </summary>
        public EnumProjectStatus Status { get; set; }
        /// <summary>
        /// 图片地址
        /// </summary>
        public string ImageUrl { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 是否关注：1关注,(非1)2未关注
        /// </summary>
        public EnumTrue Mark { get; set; }
        /// <summary>
        /// 坐标 X,Y
        /// </summary>
        public string Location { get; set; }


        /// <summary>
        /// 所属机构
        /// </summary>
        public string DepartName { get; set; }
        /// <summary>
        /// 投资总额（万）
        /// </summary>
        public decimal? TotalInCome { get; set; }
        /// <summary>
        /// 工期
        /// </summary>
        public string TakeLimit { get; set; }
        /// <summary>
        /// 是否重点 1是 2否
        /// </summary>
        public EnumTrue IsImportant { get; set; }
        /// <summary>
        /// 是否立项 1是 2否
        /// </summary>
        public EnumTrue IsApprove { get; set; }


        /// <summary>
        /// 建设单位
        /// </summary>
        public string CompanyName { get; set; }
        /// <summary>
        /// 建设单位联系人
        /// </summary>
        public string CompanyLinkman { get; set; }
        /// <summary>
        /// 建设单位联系电话
        /// </summary>
        public string CompanyLinkphone { get; set; }
        /// <summary>
        /// 建设单位联系地址
        /// </summary>
        public string CompanyAddress { get; set; }
    }

    public static class StaticProjectsValues
    {
        /// <summary>
        /// 检查是否是系统信息，如果是则抛出异常
        /// </summary>
        /// <param name="id"></param>
        public static void CheckIsSystemInfo(Guid id)
        {
            if (id.ToString().Contains(StaticUserIds.BaseId))
                throw new UserFriendlyException("您的请求无效", "当前用户没有权限删除");
        }

        /// <summary>
        /// 检查是否是系统信息，如果是则抛出异常
        /// </summary>
        /// <param name="list"></param>
        public static void CheckIsSystemInfo(List<Projects> list)
        {
            foreach (var item in list)
            {
                CheckIsSystemInfo(item.Id);
            }
        }

        /// <summary>
        /// 项目一标段标识
        /// </summary>
        public static Guid Project1Id = Guid.Parse($"{StaticUserIds.BaseId}000000000001");

        /// <summary>
        /// 项目二标段标识
        /// </summary>
        public static Guid Project2Id = Guid.Parse($"{StaticUserIds.BaseId}000000000002");

        /// <summary>
        /// 项目三标段标识
        /// </summary>
        public static Guid Project3Id = Guid.Parse($"{StaticUserIds.BaseId}000000000003");
    }
}
